package com.woniuxy.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.woniuxy.entity.BeforeQueryData;
import com.woniuxy.entity.FinaFow;
import com.woniuxy.service.FinaFowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公司流水记录Controller
 */
@RestController
@RequestMapping("/finaFow")
public class FinaFowController extends BaseController {

    @Autowired
    private FinaFowService finaFowService;


    /**
     * 初始化银行流水记录页面
     *
     * @return
     */
    @GetMapping("/listBankFlow")
    public TableDataInfo initFinaFowPage() {
        startPage();
        List<FinaFow> allFinaFow = finaFowService.initFinaFowPage();
        return getDataTable(allFinaFow);
    }

    /**
     * 增加银行流水录入
     *
     * @param finaFow
     * @return
     */
    @PostMapping("/addBankFlow")
    public AjaxResult addFinaFow(@RequestBody FinaFow finaFow) {
        return finaFowService.addFinaFow(finaFow);
    }

    /**
     * 修改银行流水信息
     *
     * @param finaFow
     * @return
     */
    @PutMapping("/updateBankFlow")
    public AjaxResult updateFinaFow(@RequestBody FinaFow finaFow) {
        return finaFowService.updateFinaFow(finaFow);
    }


    /**
     * 银行流水动态多条件查询
     *
     * @param finaFow
     * @return
     */
    @PostMapping("/queryBankFlow")
    public TableDataInfo queryBankFlow(@RequestBody BeforeQueryData beforeQueryData) {
        startPage();
        if(beforeQueryData.getDates()!=null){
            if(beforeQueryData.getDates().length==0){
                beforeQueryData.setDates(null);
            }
        }
        List<FinaFow> allFinaFow = finaFowService.queryBankFlow(beforeQueryData);
        return getDataTable(allFinaFow);
    }



    /**
     * 初始化现金流水记录页面
     *
     * @return
     */
    @GetMapping("/listCashFlow")
    public TableDataInfo listCashFlow() {
        startPage();
        List<FinaFow> allFinaFow = finaFowService.listCashFlow();
        return getDataTable(allFinaFow);
    }

    /**
     * 现金流水录入
     *
     * @param finaFow
     * @return
     */
    @PostMapping("/addCashFlow")
    public AjaxResult addCashFlow(@RequestBody FinaFow finaFow) {
        return finaFowService.addCashFlow(finaFow);
    }

    /**
     * 现金流水信息修改
     *
     * @param finaFow
     * @return
     */
    @PutMapping("/updateCashFlow")
    public AjaxResult updateCashFlow(@RequestBody FinaFow finaFow) {

        return finaFowService.updateCashFlow(finaFow);
    }

    /**
     * 现金流水动态多条件查询
     *
     * @param finaFow
     * @return
     */
    @PostMapping("/queryCashFlow")
    public TableDataInfo queryCashFlow(@RequestBody BeforeQueryData beforeQueryData) {
        startPage();
        if(beforeQueryData.getDates()!=null){
            if(beforeQueryData.getDates().length==0){
                beforeQueryData.setDates(null);
            }
        }
        List<FinaFow> allFinaFow = finaFowService.queryCashFlow(beforeQueryData);
        return getDataTable(allFinaFow);
    }






}
